// 求和相关的配置
// const countOptions = {
export default {
  // 命名空间是否开启，默认是false
  namespaced: true,
  actions: {
    jiaOdd(context, value) {
      console.log("actions中的jiaOdd被调用了", context, value);
      console.log("处理了一些事情---jiaOdd");
      if (context.state.sum % 2) {
        context.commit("JIA", value);
        // context.state.sum += value;      // 乱拳打死老师傅
      }
    },
    jianWait(context, value) {
      console.log("actions中的JIANWAIT被调用了", context, value);
      setTimeout(() => {
        context.commit("JIA", value);
      }, 1000);
    }
  },
  mutations: {
    JIA(state, value) {
      // console.log("mutations中的JIA被调用了", state, value);
      state.sum += value
    },
    JIAN(state, value) {
      // console.log("mutations中的JIAN被调用了", state, value);
      state.sum -= value
    }
  },
  state: {
    sum: 0,   // 当前的和
    school: '尚硅谷',
    subject: '前端'
  },
  getters: {
    bigSum(state) {
      return state.sum * 10
    }
  }
}